package com.dtagri.fjwlw.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

import com.dtagri.fjwlw.adapter.viewholders.CheckAreaDlgViewHolder;
import com.dtagri.fjwlw.bean.SmallArea;

/**
 * @author wxjn
 * 
 */
public class CheckAreaDlgAdapter extends
		CommonAdapter<SmallArea, CheckAreaDlgViewHolder> {

	public CheckAreaDlgAdapter(Context context, List<SmallArea> mDataSet) {
		super(context, mDataSet);
	}

	@Override
	protected CheckAreaDlgViewHolder createViewHolder() {
		return new CheckAreaDlgViewHolder();
	}

	@Override
	protected void setItemData(final int position,
			CheckAreaDlgViewHolder viewHolder, View rootView) {
		SmallArea smallArea = mDataSet.get(position);
		viewHolder.areaName.setText(smallArea.getSmallName());
		viewHolder.checkBox.setChecked(smallArea.isChecked());
		viewHolder.checkBox
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(CompoundButton arg0,
							boolean arg1) {
						mDataSet.get(position).setChecked(arg1);
					}
				});

	}

}
